﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace SnakesAndLaddersMod
{
    public class InputHandler
    {
        #region Fields

        public KeyboardState CurrentKeyboardStates;
        public KeyboardState LastKeyboardStates;

        

        #endregion

        public InputHandler()
        {
            

            CurrentKeyboardStates = new KeyboardState();
            LastKeyboardStates = new KeyboardState();
        }

       

        public void Update()
        {
            /*
            if(currWiimote.WiimoteState.ButtonState.B)
                Console.WriteLine("Wiimote X: " + currWiimote.WiimoteState.MotionPlusState.RawValues.X + " Y: " + currWiimote.WiimoteState.MotionPlusState.RawValues.Y + " Z: " + currWiimote.WiimoteState.MotionPlusState.RawValues.Z);
            if(currWiimote.WiimoteState.ButtonState.A)
                Console.WriteLine("Accel X: " + currWiimote.WiimoteState.AccelState.Values.X + " Y: " + currWiimote.WiimoteState.AccelState.Values.Y + " Z: " + currWiimote.WiimoteState.AccelState.Values.Z);
            */

            LastKeyboardStates = CurrentKeyboardStates;
            CurrentKeyboardStates = Keyboard.GetState();
        }

        public bool IsNewKeyPress(Keys key)
        {
            return CurrentKeyboardStates.IsKeyDown(key) && LastKeyboardStates.IsKeyUp(key);
        }

        #region Button checks...
        //Checks if a player pressed the "Select Button"
        public bool IsMenuSelect()
        {
            return IsNewKeyPress(Keys.Enter);
        }

        //Checks if a player pressed the "Back button"
        public bool IsMenuBack()
        {
            return IsNewKeyPress(Keys.Escape);
        }

        public bool IsMenuUp()
        {

            return (IsNewKeyPress(Keys.Up));
        }

        public bool IsMenuDown()
        {

            return IsNewKeyPress(Keys.Down);
        }
        #endregion
    }
}
